#include<iostream>
#include<vector>

using namespace std;

struct NODE{
    int val;
    struct NODE* next;
    //空构造函数
    NODE(){
        val=0;
        next=nullptr;
    }
    NODE(int x){
        val=x;
        next=nullptr;
    }
};
class Queue{
private:
    NODE* head;
    NODE* tail;
public:
    Queue(){
        head=tail=new NODE();//初始化为首尾节点相同
        tail->next=head;
    }
    void push(int x){
        if(full()){//如果满了，就需要生成新节点
            auto newNode=new NODE(x);
            newNode->next=tail->next;
            tail->next=newNode;
            tail=tail->next;
        }else{//如果没有满，那么就直接赋值
            tail->next->val=x;
            tail=tail->next;
        }
    }

    int pop(){
        if(empty()){
            return -1;
        }else{
            int temp=head->next->val;
            head=head->next;
            return temp;
        }
        
    }
    
    bool empty(){
        return this->head==this->tail;
    }
    bool full(){
        return tail->next==head;
    }
};
void test(vector<int> v){
    Queue q;

    for(auto var: v){
        if(var==-1){
            cout<<"pop: "<<q.pop()<< endl;
        }else{
            cout<<"push: ";
            q.push(var);
        }
    }
}
int main(int argc,char* argv[]){
    vector<int> t1={1,2,3,4,-1,-1,-1,-1,-1};
    test(t1);
    return 0;
}